/*
 * @Author: Otway
 * @Date: 2019-01-09 11:16:08
 * @LastEditors: Otway
 * @LastEditTime: 2019-08-30 18:50:09
 * @copyright: h-visions
 */
import React, { PureComponent } from 'react';
import {
    Row,
    Col,
    Form,
    Input,
} from 'antd';
const FormItem = Form.Item;
const formItemLayout = {
    // 抽屉里面Form。二列的布局比例
    labelCol: {
        span: 6
    },
    wrapperCol: {
        span: 18
    }
};
class AddFrom extends PureComponent {
    render() {
        const {
            formData,
            one,
            form: { getFieldDecorator },
        } = this.props;
        return (
            <Form >
                <Row>
                    <Col span={24}>
                        <FormItem {...formItemLayout} label={'组别代号:'}>
                            {getFieldDecorator('groupCode', {
                                initialValue: one ? formData.groupCode : null,
                                rules: [
                                    {
                                        required: true,
                                        message: '组别代号为空'
                                    }
                                ],
                                getValueFromEvent: (event) => {
                                    return event.target.value.replace(/\s+/g, "")
                                },
                            })(<Input placeholder='输入组别代号' allowClear maxLength={20} />)}
                        </FormItem>
                    </Col>
                    <Col span={24}>
                        <FormItem {...formItemLayout} label={'装配组别:'}>
                            {getFieldDecorator('groupName', {
                                initialValue: one ? formData.groupName : null,
                                rules: [
                                    {
                                        required: true,
                                        message: '装配组别为空'
                                    }
                                ],
                                getValueFromEvent: (event) => {
                                    return event.target.value.replace(/\s+/g, "")
                                },
                            })(<Input placeholder='输入装配组别' allowClear maxLength={20} />)}
                        </FormItem>
                    </Col>
                    <Col span={24}>
                        <FormItem {...formItemLayout} label={'备注:'}>
                            {getFieldDecorator('remark', {
                                initialValue: one ? formData.remark : '',
                                rules: [
                                    {
                                        required: false,
                                        message: '备注'
                                    }
                                ],
                                getValueFromEvent: (event) => {
                                    return event.target.value.replace(/\s+/g, "")
                                },
                            })(<Input placeholder='输入备注' allowClear maxLength={20} />)}
                        </FormItem>
                    </Col>
                </Row>
            </Form>
        );
    }
}

export default Form.create()(AddFrom);
